<!-- addEditRole.html 2017-02-02 00:23:16-->
#@HplusLayout()
#define content()
	<div style="padding:10px 15px 0 15px">
		<form id="form" class="form-horizontal required-validate" method="post" action="saveDeptUser" onsubmit="return validateCallback(this,thisDialogAjaxDone)" novalidate="novalidate">
			<input type="hidden" name="id" value="#(id)"/>
			<input type="hidden" id="ids" name="ids" value="#(ids)"/>
			<div>
				<input type="text" style="width:200px;display: inline-block;height: 30px;font-size: 12px" class="form-control" id="keyword"  placeholder="账户、姓名模糊查询"/>
				<button type="button" onclick="search()" class="btn btn-sm btn-success">搜索</button>
			</div>
			<div class="form-group">
	    	<div class="col-xs-6">
	    		<h4>待选：</h4>
	    		<select id="left" size="15" style="width: 100%;height:300px" multiple="multiple">
	    			#for(item:leftList)
	    				<option value="#(item.id)">#(item.name)(#(item.username))</option>
	    			#end
	    		</select>
	    	</div>
	      <div class="col-xs-1" style="text-align: center;padding: 0">
	      	<br/><br/>
	      	<br/><br/>
	      	<input type="button" value=">>" id="rightMove"/><br/><br/>
					<input type="button" value="<<" id="leftMove"/>
				</div>
	      <div class="col-xs-5">
	    		<h4>已选：</h4>
	    		<select id="right" size="15" style="width: 100%;height:300px" multiple="multiple">
	    			#for(item:rightList)
	    				<option value="#(item.id)">#(item.name)(#(item.username))</option>
	    			#end
	    		</select>
	      </div>
	    </div>
	    <div class="form-group">
	    	<div class="col-xs-5 col-xs-offset-4">
	      	<button type="submit" class="btn btn-primary">保存内容</button>
	      </div>
	    </div>
	  </form>
  </div>
#end
#define js()
<script src="#(res_path)/hplus/js/plugins/validate/jquery.validate.min.js"></script>
<script src="#(res_path)/hplus/js/plugins/validate/messages_zh.min.js"></script>
#end
#define jsFunction()
  <script>
	  //双击右移
	  $("#left").dblclick(function(){
		  $("#right").append($("#left option:selected"));
		  selectAllValue();
	  });
	  //双击左移
	  $("#right").dblclick(function(){
		  $("#left").append($("#right option:selected"));
		  selectAllValue();
	  });
		//批量右移
		$("#rightMove").click(function(){
		  $("#right").append($("#left option:selected"));
			selectAllValue();
		});
		//批量左移
		$("#leftMove").click(function(){
		  $("#left").append($("#right option:selected"));
			selectAllValue();
		});
		function selectAllValue(){
			var ids = "";
			$("#right").find("option").each(function() {
				ids = ids+$(this).val()+",";
			});
			if(ids!="") {
				ids = ids.substring(0,ids.length-1);
			}
			$("#ids").val(ids);
		}
		function thisDialogAjaxDone(json){
			hplus.ajaxDone(json);
			if (json["result"] == "success"){
				parent.layer.msg(json.message);
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index);
			}
		}
		function search(){
			$.ajax({
				url:"loadNotInDeptUserList",
				data:{id:#(id),ids:$("#ids").val(),keyword:$("#keyword").val()},
				dataType:"json",
				success:function(data){
					if(data.result=="success"){
						$("#left").html("");
						$.each(data.leftList,function(index,item){
							$("#left").append("<option value='"+item.id+"' selected='selected'>"+item.name+"("+item.username+")</option>")
						});
					}
				}
			})
		}
  </script>
#end